package dfbz.com.controller.article;

import dfbz.com.controller.BaseServlet;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;

@WebServlet("/article/*")
public class ArticleServlet extends BaseServlet {


    public void list(HttpServletRequest request, HttpServletResponse response) {
        try {
            String currentPage = request.getParameter("currentPage");
            String search = request.getParameter("search");

            int page = 1;
            if (null != currentPage) {
                page = Integer.parseInt(currentPage);
            }

            if (null != search) {
                String encode = URLEncoder.encode(search, "UTF-8");
                response.sendRedirect(request.getContextPath() + "/view/articleList?page=" + page + "&search=" + encode);
            } else {
                response.sendRedirect(request.getContextPath() + "/view/articleList?page=" + page);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }


}
